home *** CD-ROM | disk | FTP | other *** search
- Path: kbad.eglin.af.mil!rpi!not-for-mail
- From: Matt Young <youngm@interramp.com>
- Newsgroups: comp.lang.c++,comp.lang.c++.moderated
- Subject: Re: Help with IOStreams needed!
- Date: 16 Apr 1996 20:10:40 -0000
- Organization: PSI Public Usenet Link
- Sender: cppmods@netlab.cs.rpi.edu
- Approved: Dietmar.Kuehl@uni-konstanz.de
- Message-ID: <4l0us0$spi@netlab.cs.rpi.edu>
- References: <4kupd8$khj@netlab.cs.rpi.edu>
- NNTP-Posting-Host: netlab.cs.rpi.edu
- X-Original-Date: Tue, 16 Apr 1996 11:29:10 -0700
-
- Victor Muslin wrote:
- >
- > I am new to IOStreams, so please pardon if this is a silly question...
- >
- > I open a file as an ofstream. When I write to it I would like to lock it to
- > ensure that no other process can write until I am done. In C I could've used
- > an flock() to which I would pass a file descriptor obtained from open(). How
- > do I do I find the file descriptor associated with an ofstream (or ostream for
- > that matter)? Or, is there a better way to lock an output stream in C++?
- >
- > If you could copy your reply to vmuslin@prodigy.com I would appreciate it.
- >
- > {Those who post questions to a newsgroup are expected to read the
- > newsgroup for the reply. See the netnews netiquette guide. -mod}
- >
- > Thanks.
- >
- > [ Articles to moderate: mailto:c#include <fstream.h>
-
-
- ++-submit@netlab.cs.rpi.edu ]
- > [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- > [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- > [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-
-
- You can get the file descriptor from you ofstream this way:
-
-
- ofstream ofs("junk.txt");
-
- int fd = ofs.rdbuf()->fd();
-
- [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
- [ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
- [ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
- [ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
-